package shuaige.jdk.stream.collectors相关的方法.汇总和统计相关;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class MinBy和MaxBy {
    /**
     * 生成一个用于获取最小/最大值的Optional结果的Collector。
     */
    public static void main(String[] args) {
        List<String> list = Arrays.asList("123", "456", "789", "1101", "212121121", "asdaa", "3e3e3e", "2321eew");
        System.out.println(list.stream().collect(Collectors.maxBy((a, b) -> a.length() - b.length())));
        System.out.println(list.stream().collect(Collectors.minBy((a, b) -> a.length() - b.length())));
    }

}
